import axios from 'axios'

// create an axios instance
const lyService = axios.create({
  baseURL: process.env.VUE_APP_LiYu_BASE_API, // url = base url + request url
  // withCredentials: true, // send cookies when cross-domain requests
  timeout: 5000 // request timeout
})
// 请求拦截器
lyService.interceptors.request.use(config => {
  return config
}, error => {
  // do something with request error
  console.log(error) // for debug
  return Promise.reject(error)
}
)
// 请求拦截器

// 响应拦截器
lyService.interceptors.response.use(response => {
  const res = response.data
  return res
},
error => {
  console.log('err' + error) // for debug
  return Promise.reject(error)
}
)

export default lyService
